package com.nacos.nacosproducer;

import com.sun.xml.internal.messaging.saaj.util.Base64;

import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

/**
 * @author wenl
 * @version V2.0
 * @project 自己的框架
 * @package com.nacos.nacosproducer
 * @date 2020/4/14
 * @describe
 */
public class KeyPairGeneratorTest {


    public static void main(String[] args) throws NoSuchAlgorithmException {
        KeyPairGenerator key = KeyPairGenerator.getInstance("RSA");

        key.initialize(1024, new SecureRandom());
        System.out.println(key.generateKeyPair().getPublic().getEncoded());
        System.out.println("---");
        System.out.println(key.generateKeyPair().getPrivate().getEncoded());

        System.out.println(Base64.encode(key.generateKeyPair().getPublic().getEncoded()));

    }
}
